<?php
if (!defined('IN_XLP')) {
    exit('Access Denied');
}
$Document = array(
    'pageid' => 'user-index', //页面标示
    'pagename' => '群组类型管理', //当前页面名称
    'mycss' => array(), //加载的css样式表
    'myjs' => array(), //加载的js脚本
	'footerjs'=>array('content/jquery.smoothConfirm'),
    'head' => true, //加载头部文件
);

include getTpl('header', 'public');
?>
<!--顶部导航 开始-->
<?php include getTpl('top', 'public');?>
<!--顶部导航 结束-->
<!--左侧菜单 开始-->
<?php include getTpl('nav', 'public');?>
<!--左侧菜单 结束-->
<!--主体 开始-->
<!-- content -->
  <section id="content">
    <!-- main padder --> 
    <section class="main padder">
        <div class="clearfix"> 
			<h4><i class="fa fa-table"></i><?php echo trim($Document['pagename'],'_');?></h4> 
        </div>
        <div class="row">
			<!-- table 11 -->
			<div class="col-lg-12"> 
            <!---->
          <div class="panel-body">
            <div class="row text-small">
              <div class="col-sm-8">
              <a class="btn btn-default" href="<?php echo U('wxgroup/field_add');?>">新建类型</a>
               <div data-resize="auto" class="select btn-group" style="margin-left:10px"> 
                  <button class="btn btn-white dropdown-toggle" data-toggle="dropdown" type="button"><span class="dropdown-label">创建方式</span> <span class="caret"></span></button> 
                <ul class="dropdown-menu">
                <li data-value="0" <?php if(!$formtype){echo 'class="active"';}?>><a href="<?php echo U('wxgroup/field');?>">全部</a></li>
                <?php
                foreach($formtypelist as $key=>$val){
                ?>
                <li data-value="<?php echo $key;?>" <?php if($formtype==$key){echo 'class="active"';}?>><a href="<?php echo U('wxgroup/field',array('formtype'=>$key));?>"><?php echo $val;?></a></li>
                <?php
				}
                ?>
                </ul>
                </div>
              </div>
              <div class="col-sm-4">
                <form action="<?php echo U(ACTION_NAME.'/field');?>" method="get" name="form1" target="_self">
                  <div class="input-group">
                    <input type="text" name="q" class="input-sm form-control" placeholder="请输入类型名称关键字..." />
                    <input name="g" type="hidden" value="<?php echo GROUP_NAME;?>" />
                    <input name="c" type="hidden" value="<?php echo ACTION_NAME;?>" />
                    <input name="m" type="hidden" value="<?php echo MODEL_NAME;?>" />
                    <span class="input-group-btn">
                    <button class="btn btn-sm btn-white" type="submit">搜索</button>
                    </span> </div>
                </form>
              </div>
            </div>
          </div>
          <!---->
                <form method="post" id="fieldForm">
				<section class="panel"> 
					<div class="table-responsive"> 
						<table class="table table-striped b-t text-small"> 
							<thead>
                              <tr>
                                <th align="center">ID</th>
                                <th align="center">类型名称</th>
                                <th align="center">创建方式</th>
                                <th align="center">显示顺序</th>
                                <th align="center" width="120">操作</th>
                              </tr>
                            </thead>
                            <tbody>
                            <?php
                            if ($rs){
                                foreach($rs as $val){
                            ?>
                              <tr id="list_detail_<?php echo $val['fieldid'];?>">
                                <td><?php echo $val['fieldid'];?></td>
                                <td><?php echo $val['title'];?></td>
                                <td><?php echo $formtypelist[$val['formtype']];?></td>
                                <td><input type="text" name="displayorder[<?php echo $val['fieldid'];?>]" value="<?php echo $val['displayorder'];?>" size="5" class="form-control" style="width:10px; text-align:center;"></td>
                                <td>
                                <div class="btn-group"> 
                                    <button class="btn btn-white btn-xs dropdown-toggle" data-toggle="dropdown">操作<span class="caret"></span></button> 
                                     <ul class="dropdown-menu" style="width:95px">
                                        <li><a href="<?php echo U('wxgroup/field_edit',array('id'=>$val['user_id']));?>">编辑</a></li> 
                                        <li><a href="javascript:;" rel="<?php echo $val['user_id'];?>" class="delete">删除</a></li>
                                    </ul> 
								</div>
                                </td>
                              </tr>
                              <?php
                                }
                            }else{
                              ?>
                             <tr>
                                <td colspan="8" align="center">暂无数据</td>
                              </tr>
                            <?php
                            }
                            ?>
                            </tbody> 
						</table> 
					</div> 
         			<footer class="panel-footer">
                    <div class="row" style=" position:relative;">
                      <?php
                      if ($rs){
                      ?>
                      <button class="btn btn-default" href="<?php echo U('wxgroup/field_asd');?>" style=" position:absolute; top:1em; left:45%; z-index:999;">更新排序</button>
                      <?php
					  }
                      ?>
                      <div class="col-sm-12 text-right text-center-sm">
                        <?php echo page($total,$p,'',10,'p');?></div>
                    </div>
                  </footer>
				</section>
                </form> 
			</div> 
			<!--/ table 11 -->

        </div> 
    </section>
    <!--/ main padder -->  
  </section> 
  <!--/ content --> 
<!--主体 结束-->
<script>
$(function(){
	$('.delete').click(function(){
		var id=$(this).attr('rel');
	  $(this).smoothConfirm("确认删除该帐户吗？", {
		  ok: function() {
			  Msg.loading();
			  $.post('<?php echo U('user/delete');?>',{"id":id},function(result){
				  Msg.hide();
				  if (result.status==1){
					  $("#list_detail_"+id).fadeOut();
				   }else{
					  Msg.error(result.info);
				  }
			  },'json');
		  },
		  cancel: function() {
			  return false;
		  }
	  });
	  $("body").click();//取消弹出层对对话框的遮蔽
	  return false;
	});
	$(".setting-status").click(function(){
		var id=$(this).attr('rel'),act=$(this).attr('act');
	  	Msg.loading();
		$.post('<?php echo U('user/deal');?>',{"id":id,"act":act},function(result){
			Msg.hide();
			if (result.status==1){
				$("#work-status-"+id).html(result.data);
			}else{
				Msg.error(result.info);
			}
		},'json');
	  $("body").click();
	  return false;
	});
	$('#fieldForm').submit(function(){
		$.post('<?php echo U('wxgroup/field');?>',$(this).serialize(),function(result){
			Msg.hide();
			if (result.status==1){
				Msg.ok('更新成功',1000);
			}else{
				Msg.error(result.info);
			}
		//});
		},'json');
		return false;
	});
})
</script>
<?php
include getTpl('footer', 'public');
?>